# This Python file uses the following encoding: utf-8
import sys
from pathlib import Path

from PySide6.QtGui import QGuiApplication
from PySide6.QtQml import QQmlApplicationEngine


if __name__ == "__main__":
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()
    # 设置 QML 模块路径

    #采用qmldir的方式需要addImportPath 而直接import文件路径额定方式不需要 下面代码addImportPath
    engine.addImportPath(".");
    engine.addImportPath("./qml"); #路径用正斜杠/或者反斜杠\ 都可以

    qml_file = Path(__file__).resolve().parent / "main.qml"
    engine.load(qml_file)
    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec())
